#include<iostream>
#include<vector>

using namespace std;

int searchInsert(vector<int>& nums, int target) {

    int left = 0, right = nums.size() - 1, mid = 0;
    while (left < right) {
        mid = left + (right - left) / 2;
        if (nums[mid] < target)
            left = mid + 1;
        else
            right = mid;
    }
    if (nums[left] <= target) return left +1;
    else return left;

}


int findMin(vector<int>& nums) {
    int left = 0, right = nums.size() - 1;
    int x = nums[right];
    while (left < right)
    {
        int mid = left + (right - left ) / 2;
        if (nums[mid] > x) left = mid + 1;
        else right = mid;
    }
    return left;
}

int main()
{
    vector<int> v = { 3,4,5,1,2 };
    int ret = findMin(v);

	return 0;
}